<?php
include_once 'mysql_connect.php';
$username=$_POST['username'];
$password=$_POST['password'];
$cpassword=$_POST['cpassword'];
$submit=$_POST['submit'];

if($submit=='修改')
{
	$strlen_pw=strlen("$password");
	
	if(($strlen_pw>33)||($strlen_pw<7))
	{	
		$message="此密码长度为<font color=red>$str_pw</font><br /><a href=forgot.php>请确保密码长度为7-32之间</a><br />";
		header("location:show.php?show=$message");
	}
	elseif($password != $cpassword)
	{
		$message="<a href=forgot.php>2 次密码不一致</a><br />";
		header("location:show.php?show=$message");	
	}
	else
	{
		$password=md5($cpassword);
		if(mysql_query(" UPDATE `bbs_member` SET `password`='$password' WHERE `username`='$username' "))
		{
			$message="<font color=red><a href=login.php>密码修改成功</a></font>";
			header("location:show.php?show=$message");
		}
		else
		{
			$message="<font color=red><a href=forgot.php>密码修改失败</a></font>";
			header("location:show.php?show=$message");
		}
	}

}
if($submit=='登陆')
{
	header("location:login.php");
}
if($submit=='注册')
{
	header("location:register.php");
}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>修改密码</title>
</head>

<body>
&nbsp;
<hr />
&nbsp;
<form action="forgot.php" method="post">
<table align="center" border="1">
	<tr>
		<td align="center" colspan="2">密码修改</td>
	</tr>
	<tr>
		<td>账号:</td><td><input type="text" name="username" size="25" /></td>
	</tr>
	<tr>
		<td>密码:</td><td><input type="password" name="password" size="25" /></td>
	</tr>
	<tr>
		<td>确认密码:</td><td><input type="password" name="cpassword" size="25" /></td>
	</tr>
	<tr>
		<td colspan="2">
			<input type="submit" name="submit" value="修改" />
			<input type="submit" name="submit" value="登陆" />
			<input type="submit" name="submit" value="注册" />
		</td>
	</tr>
</table>
</form>
</body>
</html>
